local modname = "seaweedfs_upload"
local _M = { _VERSION = '0.0.1' }
_G[modname] = _M

local uuid = require("resty.seaweedfs.utils.uuid")

local ngx_re_sub = ngx.re.sub
local ngx_re_match = ngx.re.match
local ngx_req_set_uri = ngx.req.set_uri

local ngx_req = ngx.req
local ngx_var = ngx.var
local ngx_log = ngx.log
local ngx_print = ngx.print
local ngx_exit = ngx.exit

local mt = {
    __call = function(_)
        uuid.seed()
        local region = ngx_var[1]
        local new_uri = "/" .. region .. "/" .. uuid.generate_v4()
        ngx_log(ngx.INFO, "new_uri=" .. new_uri)
        ngx_req_set_uri(new_uri)
        --return ngx_exit(ngx.HTTP_OK)
    end,
}

return setmetatable(_M, mt)
